package com.seele.tigerwallet.ui.utils;


import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.seele.tigerwallet.R;

public class TypefaceUtils {


    private static BaseViewHolder textTypefaceFromHolder;

    public static void setTextTypeface(Context context, TextView textView, String path) {
        AssetManager mgr = context.getAssets();


//        Typeface tf= Typeface.createFromAsset(mgr, "fonts/ttf.ttf");//根据路径得到Typeface
        Typeface tf= Typeface.createFromAsset(mgr,         path);//根据路径得到Typeface

        textView.setTypeface(tf);//设置字体


    }


    public  static  void setCenturyGotHic(TextView textView,Context context){
        try {
            if (null!=textView){
                AssetManager mgr = context.getAssets();
                Typeface tf= Typeface.createFromAsset(mgr, "fonts/CENTURY_GOTHIC.TTF");//根据路径得到Typeface
                textView.setTypeface(tf);//设置字体
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }



    public  static  void setCenturyGothicBold(TextView textView,Context context){
        try {
            if (null!=textView){
                AssetManager mgr = context.getAssets();
                Typeface tf= Typeface.createFromAsset(mgr, "fonts/CENTURY_GOTHIC_BOLD.TTF");//根据路径得到Typeface
                textView.setTypeface(tf);//设置字体
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }




    public  static  void setCenturyDINConBol(TextView textView,Context context){
        try {
            if (null!=textView){
                AssetManager mgr = context.getAssets();
                Typeface tf= Typeface.createFromAsset(mgr, "fonts/DINConBol.ttf");//根据路径得到Typeface
                textView.setTypeface(tf);//设置字体
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    public  static  void setFuturaMediumBT(TextView textView,Context context){
        try {
            if (null!=textView){
                AssetManager mgr = context.getAssets();
                Typeface tf= Typeface.createFromAsset(mgr, "fonts/ViabtcAlternateBold.ttf");//根据路径得到Typeface
                textView.setTypeface(tf);//设置字体
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }




    public  static  void setCenturyGothicBoldItalic(TextView textView,Context context){
        try {
            if (null!=textView){
                AssetManager mgr = context.getAssets();
                Typeface tf= Typeface.createFromAsset(mgr, "fonts/CENTURY_GOTHIC_BOLD_ITALIC.TTF");//根据路径得到Typeface
                textView.setTypeface(tf);//设置字体
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }



    public  static  void setCenturyGothicItalic(TextView textView,Context context){
        try {
            if (null!=textView){
                AssetManager mgr = context.getAssets();
                Typeface tf= Typeface.createFromAsset(mgr, "fonts/CENTURY_GOTHIC_ITALIC.TTF");//根据路径得到Typeface
                textView.setTypeface(tf);//设置字体
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }


    public static void setTextTypefaceFromHolder(BaseViewHolder helper,Context mContext) {

        TextView name = helper.getView(R.id.token_name_tv);
        TypefaceUtils.setCenturyGothicBold(name, mContext);

        TextView balance = helper.getView(R.id.token_balance_tv);
        TextView total = helper.getView(R.id.token_total_tv);
        TypefaceUtils.setCenturyGothicBold(balance, mContext);
        TypefaceUtils.setCenturyGothicBold(total, mContext);

    }
}
